package com.andnnl;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;

/**
 * Created by chenss on 2017/9/27.
 */
public class URLEncodeTest {
    public static void main(String[] args) throws UnsupportedEncodingException {
//        String s=URLEncoder.encode("仅剩4天！邀友返现金，限时高达2.5%返现，还能免费拿Apple Watch 3！一键打开","gbk");



        String rightStr="为了使各位老板更好地使用自由微信端和自由易网站（shop.freeyi.com），系统将在10月27日23:50进行优化升级。  \\r\\n\n" +
                "      【维护时间】  \\r\\n\n" +
                "        10月27日23:50-10月28日0:00   \\r\\n\n" +
                "      【升级影响】   \\r\\n\n" +
                "        升级期间，可能造成客户端等连接闪断，无法登陆与交易等情况，建议此期间谨慎操作。  \\r\\n\n" +
                "        祝各位老板  \\r\\n\n" +
                "生意兴隆！";
        String s=URLEncoder.encode(rightStr,"gbk");
        System.out.println(rightStr);
        System.out.println("********************************************");
        System.out.println(rightStr.replaceAll(" "," "));
        System.out.println("********************************************");
        System.out.println(s);
//        s="%D7%EE%D0%C2%B0%E6iWatch%D4%DA%B4%CB%A3%AC%BA%CD%C4%FA%B8%FC%C5%E4%C5%B6%A3%A1%BB%B9%D3%D0%D6%C7%C4%DC%C9%A8%B5%D8%BB%FA%C6%F7%C8%CB%A1%A2%D1%C7%C2%ED%D1%B7kindle%B1%B8%BA%C3%B4%FD%C1%EC%7E%C1%CB%BD%E2%CF%EA%C7%E9+http%3A%2F%2Fwww.surl.ren%2Fa%2FcOnzTz";
//        s=s.replaceAll("%3F","%20");
//费拿Apple Watch 3！一键打
//        String aa="%BD%F6%CA%A34%CC%EC%A3%A1%D1%FB%D3%D1%B7%B5%CF%D6%BD%F0%A3%AC%CF%DE%CA%B1%B8%DF%B4%EF2.5%25%B7%B5%CF%D6%A3%AC%BB%B9%C4%DC%C3%E2%B7%D1%C4%C3Apple%20Watch%203%A3%A1%D2%BB%BC%FC%B4%F2%BF%AA";
        String s2=URLDecoder.decode(s,"gbk");
        System.out.println(s2);
        //%BD%F6%CA%A34%CC%EC%A3%A1%D1%FB%D3%D1%B7%B5%CF%D6%BD%F0%A3%AC%CF%DE%CA%B1%B8%DF%B4%EF2.5%25%B7%B5%CF%D6%A3%AC%BB%B9%C4%DC%C3%E2%B7%D1%C4%C3Apple%3FWatch%3F3%A3%A1%D2%BB%BC%FC%B4%F2%BF%AA
        //%BD%F6%CA%A34%CC%EC%A3%A1%D1%FB%D3%D1%B7%B5%CF%D6%BD%F0%A3%AC%CF%DE%CA%B1%B8%DF%B4%EF2.5%25%B7%B5%CF%D6%A3%AC%BB%B9%C4%DC%C3%E2%B7%D1%C4%C3Apple%3FWatch%3F3%A3%A1%D2%BB%BC%FC%B4%F2%BF%AA

        String errorContent = "仅剩4天！邀友返现金，限时高达2.5%返现，还能免费拿Apple Watch 3 ！一键打开"; //你们的msg内容　　
        String content = "仅剩4天！邀友返现金，限时高达2.5%返现，还能免费拿Apple Watch 3 ！一键打开";//修改空格后的内容
        try {
            String e = java.net.URLEncoder.encode(errorContent,"GBK");
            String ce = java.net.URLEncoder.encode(content,"GBK");
            System.out.println(e);
            System.out.println(ce);
            String d = java.net.URLDecoder.decode(e,"GBK");
            String cd = java.net.URLDecoder.decode(ce,"GBK");
            System.out.println(d);
            System.out.println(cd);
        } catch (UnsupportedEncodingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

//        String test1 = "比亚迪平台前10分钟出现count个异常【嘉盈警示】";
        String test1 = "比亚迪平台无法访问Resin1【嘉盈警示】";
        String ce = java.net.URLEncoder.encode(test1,"utf-8");
        System.out.println(test1);
        System.out.println(ce);


        String ss2="http://112.74.161.110/alarmSms/SendAlarmSms?/alarmSms/SendAlarmSms?password=jiayingzhanghu2017&receiver=chenss&sms=%E6%AF%94%E4%BA%9A%E8%BF%AA%E5%B9%B3%E5%8F%B0%E6%97%A0%E6%B3%95%E8%AE%BF%E9%97%AEResin1%E3%80%90%E5%98%89%E7%9B%88%E8%AD%A6%E7%A4%BA%E3%80%91";
        String rs2 = java.net.URLDecoder.decode(ss2,"utf-8");
        System.out.println(rs2);

         ss2="【Laotimes】尊敬的會員LT658674您通過短信找回密碼，您的一級密碼229144二級密碼383557請儘快登錄網站修改您的密碼。【Laotimes】ສະມາສິກLT658674ທີ່ຮັກແພງທ່ານຈະໄດ້ັຮັບລະຫັດຜ່ານຄືນຈາກຂໍ້ຄວາມ, ລະຫັດຜ່ານລະດັບ1ແມ່ນ229144ລະຫັດຜ່ານລະດັບ2ແມ່ນ383557ກະລຸນາເຂົ້າເວບໄຊທ໌ຂອງທ່ານເພື່ອປ່ຽນແປງລະຫັດ.";
            rs2 = java.net.URLEncoder.encode(ss2,"utf-8");
            System.out.println(rs2);
         rs2 = java.net.URLDecoder.decode(rs2,"utf-8");
        System.out.println(rs2);


        String ss3="%A1%BE%C9%EE%DB%DA%BE%B0%CC%EF%D2%BD%D4%BA%A1%BF%D5%C5%BF%AD%B9%E2%A3%AC%C4%FA%BA%C3%A3%A1%C4%FA%D2%D1%B3%C9%B9%A6%D4%A4%D4%BC2018%C4%EA10%D4%C209%C8%D5%A3%A816%3A00-17%3A00%A3%A9%D6%D0%D2%BD%BF%C6%D3%E1%D0%CB%B8%F9%D2%BD%C9%FA%A3%AC%D4%A4%D4%BC%BA%C5181009099%A1%A3%B5%D8%D6%B7%A3%BA%B8%A3%CC%EF%C7%F8%C9%CC%B1%A8%C2%B79%BA%C5%A3%AC%B5%E7%BB%B0%A3%BA83921555%A1%A3";
        String rs3 = java.net.URLDecoder.decode(ss3,"gbk");
        System.out.println(rs3);


        ss2="你好。***";
        rs2 = java.net.URLEncoder.encode(ss2,"gbk");
        System.out.println(rs2);
        rs2 = java.net.URLDecoder.decode(rs2,"gbk");
        System.out.println(rs2);


    }
}
